import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import com.jgoodies.forms.layout.FormLayout;
import com.jgoodies.forms.layout.ColumnSpec;
import com.jgoodies.forms.layout.RowSpec;
import com.jgoodies.forms.factories.FormFactory;
import javax.swing.JDesktopPane;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JMenu;
import java.awt.FlowLayout;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.JButton;
import javax.swing.BoxLayout;
import java.awt.CardLayout;
//Java core packages
import java.awt.*;
import java.awt.event.*;
// Java extension packages
import javax.swing.*;

import org.omg.CORBA.portable.ApplicationException;
import com.jgoodies.forms.layout.Sizes;
import javax.swing.border.LineBorder;
import javax.swing.border.EtchedBorder;
import javax.swing.text.MaskFormatter;
import javax.swing.table.DefaultTableModel;


public class jframe extends JFrame {
	JPanel cardPanel;
	private JTextField textCustomerName;
	private JTextField textEmailId;
	private JTextField textAddress;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					jframe frame = new jframe();
					frame.setVisible(true);
					frame.setDefaultCloseOperation(
					         JFrame.EXIT_ON_CLOSE );
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public jframe() {
		setTitle("Airline Reservation system");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 721, 457);
		
		JMenuBar menuBar = new JMenuBar();
		setJMenuBar(menuBar);
		
		JMenu mnReservation = new JMenu("Reservation");
		menuBar.add(mnReservation);
		
		//menu "make reservation" and event handler
		JMenuItem mntmMakeReservation = new JMenuItem("Make Reservation");
		mntmMakeReservation.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
			}
		});
		mnReservation.add(mntmMakeReservation);
		
		//menu "Cancel reservation" and event handler
		JMenuItem mntmCancelReservation = new JMenuItem("Cancel Reservation");
		mntmCancelReservation.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
			}
		});
		mnReservation.add(mntmCancelReservation);
		
		
		//menu "Print reservation" and event handler
		JMenuItem mntmPrintReservation = new JMenuItem("Print Reservation");
		mntmPrintReservation.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
			}
		});
		mnReservation.add(mntmPrintReservation);
		
		//menu "Find Passenger" and event handler
		JMenuItem mntmFindPassenger = new JMenuItem("Find Passenger");
		mntmFindPassenger.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
			}
		});
		mnReservation.add(mntmFindPassenger);
		
		//menu "View Passenger List" and event handler
		JMenuItem mntmViewPassengerList = new JMenuItem("View Passenger List");
		mntmViewPassengerList.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
			}
		});
		mnReservation.add(mntmViewPassengerList);
		
		
		//menu "Exit" and event handler
		JMenu mnExit = new JMenu("Exit");
		mnExit.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
			
			}
		});
		menuBar.add(mnExit);
		getContentPane().setLayout(null);
		
		cardPanel = new JPanel();
		cardPanel.setBounds(0, 0, 705, 401);
		getContentPane().add(cardPanel);
		cardPanel.setLayout(new CardLayout(0, 0));
		
		JPanel homePanel = new JPanel();
		cardPanel.add(homePanel, "Welcome to Globetrotters Airlines");
		
		JLabel lblWelcomeToGlobetrotters = new JLabel("Welcome to GlobeTrotters Airlines");
		lblWelcomeToGlobetrotters.setFont(new Font("Tahoma", Font.BOLD, 18));
		homePanel.add(lblWelcomeToGlobetrotters);
		
		JButton btnMakeReservation = new JButton("Make Reservation");
		btnMakeReservation.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				//ShowHidePanel("Print Reservation");
			}
		});
		btnMakeReservation.setFont(new Font("Tahoma", Font.BOLD, 12));
		homePanel.add(btnMakeReservation);
		
		JPanel makeReservationPanel = new JPanel();
		makeReservationPanel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
		cardPanel.add(makeReservationPanel, "Make Reservation");
		makeReservationPanel.setLayout(new BorderLayout(0, 0));
		
		JPanel titlePanel = new JPanel();
		titlePanel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
		FlowLayout flowLayout_1 = (FlowLayout) titlePanel.getLayout();
		flowLayout_1.setVgap(6);
		makeReservationPanel.add(titlePanel, BorderLayout.NORTH);
		
		JLabel lblMakeReservation = new JLabel("Make Reservation");
		lblMakeReservation.setFont(new Font("Tahoma", Font.BOLD, 18));
		titlePanel.add(lblMakeReservation);
		
		JPanel flightPanel = new JPanel();
		flightPanel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
		makeReservationPanel.add(flightPanel, BorderLayout.WEST);
		flightPanel.setLayout(new FormLayout(new ColumnSpec[] {
				FormFactory.RELATED_GAP_COLSPEC,
				new ColumnSpec(ColumnSpec.FILL, Sizes.bounded(Sizes.DEFAULT, Sizes.constant("50dlu", true), Sizes.constant("100dlu", true)), 0),
				FormFactory.RELATED_GAP_COLSPEC,
				ColumnSpec.decode("min(100dlu;default)"),
				FormFactory.RELATED_GAP_COLSPEC,},
			new RowSpec[] {
				FormFactory.PREF_ROWSPEC,
				RowSpec.decode("8dlu"),
				FormFactory.PREF_ROWSPEC,
				RowSpec.decode("8dlu"),
				FormFactory.PREF_ROWSPEC,
				RowSpec.decode("8dlu"),
				FormFactory.PREF_ROWSPEC,
				RowSpec.decode("8dlu"),
				FormFactory.PREF_ROWSPEC,
				RowSpec.decode("8dlu"),
				FormFactory.PREF_ROWSPEC,}));
		
		JLabel lblFlightNo = new JLabel("Flight No. ");
		lblFlightNo.setFont(new Font("Tahoma", Font.BOLD, 13));
		flightPanel.add(lblFlightNo, "2, 3");
		
		JLabel lblFlightNoVal = new JLabel("A234");
		lblFlightNoVal.setFont(new Font("Tahoma", Font.PLAIN, 12));
		flightPanel.add(lblFlightNoVal, "4, 3");
		
		JLabel lblFrom = new JLabel("From");
		lblFrom.setFont(new Font("Tahoma", Font.BOLD, 13));
		flightPanel.add(lblFrom, "2, 5");
		
		JLabel lblFromVal = new JLabel("SFO");
		lblFromVal.setFont(new Font("Tahoma", Font.PLAIN, 12));
		flightPanel.add(lblFromVal, "4, 5");
		
		JLabel lblDeparting = new JLabel("Departing");
		lblDeparting.setFont(new Font("Tahoma", Font.BOLD, 13));
		flightPanel.add(lblDeparting, "2, 7");
		
		JLabel lblDepartingVal = new JLabel("09/22/2011  8.00 AM");
		lblDepartingVal.setFont(new Font("Tahoma", Font.PLAIN, 12));
		flightPanel.add(lblDepartingVal, "4, 7");
		
		JLabel lblTo = new JLabel("To");
		lblTo.setFont(new Font("Tahoma", Font.BOLD, 13));
		flightPanel.add(lblTo, "2, 9");
		
		JLabel lblJfk = new JLabel("JFK");
		lblJfk.setFont(new Font("Tahoma", Font.PLAIN, 12));
		flightPanel.add(lblJfk, "4, 9");
		
		JLabel lblArriving = new JLabel("Arriving");
		lblArriving.setFont(new Font("Tahoma", Font.BOLD, 13));
		flightPanel.add(lblArriving, "2, 11");
		
		JLabel lblArrivingVal = new JLabel("09/22/2011  3.30 PM");
		lblArrivingVal.setFont(new Font("Tahoma", Font.PLAIN, 13));
		flightPanel.add(lblArrivingVal, "4, 11");
		
				/**/
		JPanel customerPanel = new JPanel();
		customerPanel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
		makeReservationPanel.add(customerPanel, BorderLayout.CENTER);
		customerPanel.setLayout(new FormLayout(new ColumnSpec[] {
				FormFactory.RELATED_GAP_COLSPEC,
				FormFactory.DEFAULT_COLSPEC,
				FormFactory.RELATED_GAP_COLSPEC,
				ColumnSpec.decode("default:grow"),
				FormFactory.RELATED_GAP_COLSPEC,},
			new RowSpec[] {
				RowSpec.decode("min(100dlu;pref)"),
				RowSpec.decode("8dlu"),
				FormFactory.PREF_ROWSPEC,
				RowSpec.decode("8dlu"),
				FormFactory.PREF_ROWSPEC,
				RowSpec.decode("8dlu"),
				FormFactory.PREF_ROWSPEC,
				RowSpec.decode("8dlu"),
				FormFactory.DEFAULT_ROWSPEC,
				RowSpec.decode("8dlu"),}));
		
		JLabel lblCustomerName = new JLabel("Customer Name");
		lblCustomerName.setHorizontalAlignment(SwingConstants.LEFT);
		lblCustomerName.setFont(new Font("Tahoma", Font.BOLD, 13));
		customerPanel.add(lblCustomerName, "2, 3, left, default");
		
		textCustomerName = new JTextField();
		textCustomerName.setFont(new Font("Tahoma", Font.PLAIN, 13));
		customerPanel.add(textCustomerName, "4, 3, fill, default");
		textCustomerName.setColumns(10);
		
		JLabel lblEmailId = new JLabel("Email Id");
		lblEmailId.setHorizontalAlignment(SwingConstants.LEFT);
		lblEmailId.setFont(new Font("Tahoma", Font.BOLD, 13));
		customerPanel.add(lblEmailId, "2, 5, left, default");
		
		textEmailId = new JTextField();
		textEmailId.setFont(new Font("Tahoma", Font.PLAIN, 13));
		customerPanel.add(textEmailId, "4, 5, fill, default");
		textEmailId.setColumns(10);
		
		JLabel lblAddress = new JLabel("Address");
		lblAddress.setHorizontalAlignment(SwingConstants.TRAILING);
		lblAddress.setFont(new Font("Tahoma", Font.BOLD, 13));
		customerPanel.add(lblAddress, "2, 7, left, default");
		
		textAddress = new JTextField();
		textAddress.setFont(new Font("Tahoma", Font.PLAIN, 13));
		customerPanel.add(textAddress, "4, 7, fill, default");
		textAddress.setColumns(10);
		
		JLabel lblContactNo = new JLabel("Contact No. ");
		lblContactNo.setFont(new Font("Tahoma", Font.BOLD, 13));
		customerPanel.add(lblContactNo, "2, 9, left, default");
		
		MaskFormatter mf2 = new MaskFormatter("(###) ###-####");
		JFormattedTextField formattedTexttextContactNo = new JFormattedTextField(mf2);
		formattedTexttextContactNo.setFont(new Font("Tahoma", Font.PLAIN, 13));
		customerPanel.add(formattedTexttextContactNo, "4, 9, fill, default");
		
		JPanel buttonPanel = new JPanel();
		buttonPanel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
		FlowLayout flowLayout = (FlowLayout) buttonPanel.getLayout();
		flowLayout.setVgap(10);
		flowLayout.setHgap(10);
		makeReservationPanel.add(buttonPanel, BorderLayout.SOUTH);
		
		JButton btnResereve = new JButton("Reserve");
		btnResereve.setFont(new Font("Tahoma", Font.BOLD, 11));
		buttonPanel.add(btnResereve);
		
		JPanel seatPanel = new JPanel();
		seatPanel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
		makeReservationPanel.add(seatPanel, BorderLayout.EAST);
		seatPanel.setLayout(new FormLayout(new ColumnSpec[] {
				FormFactory.RELATED_GAP_COLSPEC,
				FormFactory.DEFAULT_COLSPEC,
				FormFactory.RELATED_GAP_COLSPEC,
				FormFactory.DEFAULT_COLSPEC,
				FormFactory.RELATED_GAP_COLSPEC,
				FormFactory.DEFAULT_COLSPEC,
				FormFactory.RELATED_GAP_COLSPEC,
				FormFactory.DEFAULT_COLSPEC,
				FormFactory.RELATED_GAP_COLSPEC,
				FormFactory.DEFAULT_COLSPEC,
				FormFactory.RELATED_GAP_COLSPEC,
				FormFactory.DEFAULT_COLSPEC,
				FormFactory.DEFAULT_COLSPEC,
				FormFactory.RELATED_GAP_COLSPEC,},
			new RowSpec[] {
				FormFactory.LINE_GAP_ROWSPEC,
				FormFactory.PREF_ROWSPEC,
				FormFactory.LINE_GAP_ROWSPEC,
				FormFactory.PREF_ROWSPEC,
				FormFactory.PARAGRAPH_GAP_ROWSPEC,
				FormFactory.PREF_ROWSPEC,
				FormFactory.LINE_GAP_ROWSPEC,
				FormFactory.PREF_ROWSPEC,
				FormFactory.LINE_GAP_ROWSPEC,
				FormFactory.PREF_ROWSPEC,
				FormFactory.LINE_GAP_ROWSPEC,
				FormFactory.PREF_ROWSPEC,
				FormFactory.LINE_GAP_ROWSPEC,
				FormFactory.PREF_ROWSPEC,}));
		
		JButton btn1A = new JButton("1A");
		seatPanel.add(btn1A, "2, 2");
		
		JButton btn1B = new JButton("1B");
		seatPanel.add(btn1B, "4, 2");
		
		JButton btn1C = new JButton("1C");
		seatPanel.add(btn1C, "6, 2");
		
		JButton btn1D = new JButton("1D");
		seatPanel.add(btn1D, "8, 2");
		
		JButton btn1E = new JButton("1E");
		btn1E.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
			}
		});
		seatPanel.add(btn1E, "10, 2");
		
		JButton btn1F = new JButton("1F");
		seatPanel.add(btn1F, "12, 2");
		
		JButton btn2A = new JButton("2A");
		seatPanel.add(btn2A, "2, 4");
		
		JButton btn2B = new JButton("2B");
		seatPanel.add(btn2B, "4, 4");
		
		JButton btn3A = new JButton("3A");
		seatPanel.add(btn3A, "2, 6");
		
		JButton btn3B = new JButton("3B");
		seatPanel.add(btn3B, "4, 6");
		
		JButton btn3C = new JButton("3C");
		seatPanel.add(btn3C, "6, 6");
		
		JButton btn3D = new JButton("3D");
		seatPanel.add(btn3D, "8, 6");
		
		JButton btn3E = new JButton("3E");
		seatPanel.add(btn3E, "10, 6");
		
		JButton btn3F = new JButton("3F");
		seatPanel.add(btn3F, "12, 6");
		
		/*JPanel printReservationPanel = new JPanel();
		cardPanel.add(printReservationPanel, "Print Reservation");
		
		JButton btnPrintreservation = new JButton("PrintReservation");
		btnPrintreservation.setFont(new Font("Tahoma", Font.BOLD, 12));
		printReservationPanel.add(btnPrintreservation);*/
		

	}
	
	public void ShowHidePanel(String strName){
		CardLayout cl = (CardLayout)(cardPanel.getLayout());
	    cl.show(cardPanel, strName);
	}
	
	public JPanel getCardPanel() {
		return cardPanel;
	}
	
	
}
